package com.zsd.android.eventbus;

import com.zsd.android.annotation.mode.SubscriberMethod;

public class Subscription {

    //订阅者MainActivity.class
    final Object subscriber;
    //订阅方法
    final SubscriberMethod subscriberMethod;

    public Subscription(Object subscriber, SubscriberMethod subscriberMethod) {
        this.subscriber = subscriber;
        this.subscriberMethod = subscriberMethod;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof Subscription) {
            Subscription subscription = (Subscription) obj;
            //删除官方的 subscriber == subscription.subscriberMethod
            //原因：黏性事件Bug，多次调用和移除时重新，
            return subscriberMethod.equals(subscription.subscriberMethod);
        }
        return false;
    }
}
